package ex.com.jm.food.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import ex.com.jm.food.dao.UserCompanyTypeDao;
import ex.com.jm.food.entity.CompanyType;

public class UserCompanyTypeDaoImpl extends HibernateDaoSupport implements
		UserCompanyTypeDao {

	public UserCompanyTypeDaoImpl() {
		// TODO Auto-generated constructor stub
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<CompanyType> getCompanyTypes() {
		// TODO Auto-generated method stub
		Object comtypes=this.getHibernateTemplate().execute(new HibernateCallback() {

			@Override
			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
				// TODO Auto-generated method stub
				Query query=session.createQuery("from CompanyType");
				return query.list();
			}
		});
		return (List<CompanyType>) comtypes;
	}

}
